A moving image encoder for encoding a moving image and a moving image decoder for decoding a moving image are in wide use in order to transmit or record a moving image efficiently. Typical examples of a moving image encoding method include H.264/MPEG-4 AVC (described in Non-patent Literature 1) and a method employed in KTA software which is a joint development codec in VCEG (Video Coding Expert Group).
In such an encoding method, pictures constituting a moving image are managed in a hierarchical structure constituted by (i) slices into which each of the pictures is divided, (ii) macroblocks into which each of the slices is divided, and (iii) subblocks into which each of the macroblocks is divided.
The moving image encoder encodes a moving image with respect to each block. Specifically, encoding is conducted by: (1) carrying out, with respect to each block, DCT (Discrete Cosine Transform) on a prediction residual obtained by subtracting a predicted image from an original image; (2) quantizing a DCT coefficient thus obtained; and (3) carrying out variable length coding on the quantized DCT coefficient. Generally, it is possible to reduce a coding amount by carrying out DCT/quantization/encoding on a prediction residual, but not on an original image.
The moving image encoder generates the predicted image in accordance with a locally decoded image obtained by carrying out inverse quantization/inverse DCT with respect to the quantized DCT coefficient. Examples of a method for generating a predicted image include an inter-frame prediction (inter-prediction) and an intra-frame prediction (intra-prediction). In the moving image encoder, it is selected per macro block which prediction method is to be used.
In the intra-prediction, a predicted image in a partition is generated by extrapolating from a locally decoded image in another encoded/decoded partition (hereinafter referred to as “reference partition”) which belongs to the same picture as the partition. On the other hand, in the inter-prediction, a predicted image in a partition is generated by carrying out motion compensated prediction from another encoded/decoded picture (hereinafter referred to as “reference image”) which is different from a picture to which the partition belongs. Note here that a partition is indicative of a prediction unit obtained by dividing a macroblock.
Further, in the inter-prediction of H.264/MPEG-4 AVC, it is possible to carry out weighted prediction in which an image obtained by adding on offset value to an weighted average w1×mc1+w2×mc2 of motion compensated images mc1 and mc2 generated from reference images (locally decoded images) P1 and P2 respectively is used as a predicted image to be subtracted from an encoding target image. The weighted prediction has an Explicit mode and an Implicit mode. In the moving image encoder, it can be selected per partition which mode is to be used.
In the Explicit mode, weighting factors w1 and w2 are encoded in the moving image encoder, and are decoded in the moving image decoder. On the other hand, in the Implicit mode, in both of the moving image encoder and the moving image decoder, the weighting factors w1 and w2 are set in accordance with inter-frame distances between a prediction target image (that is, an encoding target image in the moving image encoder, and a decoding target image in the moving image decoder) P and the reference images (that is, locally decoded images in the moving image encoder, and decoded images in the moving image decoder) P1 and P2. Specifically, assume that an inter-frame distance between the reference image P1 and the reference image P2 is set to td, and a distance between the reference image P1 and the prediction target image P is set to tb. Under this condition, a value of the weighting factor w2 by which the motion compensated image mc2 generated from the reference image P2 is to be multiplied is set to tb/td, and a value of the weighting factor w1 by which the motion compensated image mc1 generated from the reference image P1 is to be multiplied is set to 1-w2.
When Implicit mode weighted prediction is carried out, that is, when values of the weighting factors w1 and w2 are set to w1=1−w2 and w2=tb/td, it is possible to generate a more accurate predicted image (with a smaller difference from an encoding target image) in comparison with a case where no weighted prediction is carried out, that is, a case where values of the weighting factors w1 and w2 are set to w1=w2=0.5. This allows reducing codes in comparison with a case where no weighted prediction is carried out.